Skip to content

feat(api): PurchaseOrderHeader + Line endpoints (2 of 4 newly-migrated tables)#51

Merged
CryptoJones merged 1 commit into
masterfrom
feat/purchase-order-header-and-line-endpoints
May 17, 2026
Merged

feat(api): PurchaseOrderHeader + Line endpoints (2 of 4 newly-migrated tables)#51
CryptoJones merged 1 commit into
masterfrom
feat/purchase-order-header-and-line-endpoints

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Tracker: #49.

Summary

Two more entities from the migration. Both vendor-scoped:

  • Header via pohPovId → PurchaseOrderVendor.povCompId (new auth.getCompanyIdByPovId)
  • Line via polpoh → header → vendor.povCompId (new auth.getCompanyIdByPohId)

Full CRUD on each:

  • POST/GET/PATCH/DELETE /v1/purchaseorderheader/* (list by vendor)
  • POST/GET/PATCH/DELETE /v1/purchaseorderline/* (list by header)

After this lands, only InventoryTransactions remains from the 4-table migration without endpoints.

Test plan

  • vitest: 27 files / 191 passing (was 25 / 175)
  • Auth-contract + body-validation per entity
  • Live PG integration with the migration applied

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

…d tables)

Two more entities from the 20260517000000 migration. Both
scope auth through the vendor's povCompId via new helpers in
middleware/auth.js:

  - getCompanyIdByPovId(povId)  — header uses this for pohPovId lookup
  - getCompanyIdByPohId(pohId)  — line uses this (header → vendor → company)

Header endpoints:
  POST   /v1/purchaseorderheader
  GET    /v1/purchaseorderheader/:id
  GET    /v1/purchaseorderheader/byvendor/:id   (paginated, newest first)
  PATCH  /v1/purchaseorderheader/:id
  DELETE /v1/purchaseorderheader/:id            (soft-delete via pohArch)

Line endpoints (header-scoped via polpoh — note the lowercase
column name; matches what the migration / BACPAC actually
create rather than renaming):
  POST   /v1/purchaseorderline
  GET    /v1/purchaseorderline/:id
  GET    /v1/purchaseorderline/byheader/:id     (paginated)
  PATCH  /v1/purchaseorderline/:id
  DELETE /v1/purchaseorderline/:id              (soft-delete via polArch)

Vendor (#50) is now complete; this leaves only InventoryTransactions
from the 4-table migration without endpoints.

Tests: 27 files / 191 tests (was 25 / 175).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit 62122dc into master May 17, 2026
@CryptoJones CryptoJones deleted the feat/purchase-order-header-and-line-endpoints branch May 17, 2026 23:52
CryptoJones added a commit that referenced this pull request May 17, 2026
)

Continues the housekeeping pattern of #44 — keep the README endpoint
table and CHANGELOG \`[Unreleased]\` in sync with merged PRs.

README:
  - Append rows for the four PurchaseOrder/Inventory entities
    that gained endpoints in #50, #51, #52.

CHANGELOG (under \`[Unreleased]\`):
  - PurchaseOrder + Inventory API rollout (the tracker, #49, and
    its three PRs)
  - JSON_BODY_LIMIT env hook (#45 / #46 / #47)
  - npm audit fix + dep bumps + Snyk PR triage (#30 / #48)

Co-authored-by: Aaron K. Clark <akclark@thenetwerk.net>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant